﻿using Abp.Application.Services.Dto;
using Abp.Dependency;
using Batman.Cms.Core.Const;
using Batman.Jianbei.Forum.Core.Datas;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;

namespace Batman.Jianbei.Forum.Domains
{
    public partial class Role : ITransientDependency
    {
        private JianbeiForumDbContext context;

        public Role()
        {
            context = new JianbeiForumDbContextFactory().CreateDbContext(null);
        }

        /// <summary>
        /// 获取全部的角色
        /// </summary>
        /// <returns></returns>
        public List<NameValueDto> GetRoles()
        {
            using (context)
            {
                var roles = context.Roles.Select(t => new NameValueDto { Name = t.Name, Value = t.Id });
                return roles.ToList();
            }
        }
    }
}
